﻿$(function() {
    var piechart1 = echarts.init(document.getElementById('piechart1'),'macarons');
    option = {
        tooltip : {
            trigger: 'item',
            formatter: "{b} ({d}%)"
        },
        legend: {
            orient: 'horizontal',
            bottom: '20',
            data: ['总电量','峰值电费','平直电费','谷值电费']
        },
        backgroundColor:'#e0e0e0',
        series : [{
            type: 'pie',
            radius : '45%',
            center: ['50%', '35%'],
            data:[
                {value:1000, name:'总电量'},
                {value:500, name:'峰值电费'},
                {value:300, name:'平直电费'},
                {value:200, name:'谷值电费'}
            ],
            itemStyle: {
                emphasis: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            },
            label: {
                normal: {
	                 formatter: '{b}\n{c}元'
	            }
            }
        }]
    };
    piechart1.setOption(option);

    var piechart2 = echarts.init(document.getElementById('piechart2'),'macarons');
    option2 = {
        tooltip: {
            trigger: 'item',
            formatter: "{b}({d}%)"
        },
        legend: {
            orient: 'horizontal',
            bottom: '20',
            data:['满载','空载','停机','其他']
        },
        backgroundColor:'#e0e0e0',
        series: [{
            name:'访问来源',
            type:'pie',
            radius: ['30%', '45%'],
            center: ['50%', '35%'],
            avoidLabelOverlap: false,
            label: {
                normal: {
	                 formatter: '{b}\n{c}小时'
	            },
                emphasis: {
                    show: true,
                    textStyle: {
                        fontSize: '10',
                        fontWeight: 'bold'
                    }
                }
            },
            data:[
                {value:40, name:'满载'},
                {value:25.5, name:'空载'},
                {value:5.4, name:'停机'},
                {value:10.8, name:'其他'}
            ]
        }]
    };
    piechart2.setOption(option2);
});